//
//  UIViewController+Back.m
//  Hear
//
//  Created by mac on 2018/5/10.
//  Copyright © 2018年 mac. All rights reserved.
//

#import "UIViewController+Back.h"

@implementation UIViewController (Back)

- (void)viewDidLoad {
    
    if (self.navigationController.childViewControllers.count > 1) {
        UIButton *leftButton = [UIButton buttonWithType:0];
        leftButton.size = CGSizeMake(25, 40);
        [leftButton setImage:[UIImage imageNamed:@"Back-Arrow"] forState:UIControlStateNormal];
        [leftButton addTarget:self action:@selector(clickBack) forControlEvents:UIControlEventTouchUpInside];
        self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:leftButton];
    }
}

- (void)clickBack{
    [self.navigationController popViewControllerAnimated:YES];
}

@end
